package com.zh.jetpackmvvm.ext.lifecyle

import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import com.zh.jetpackmvvm.callback.livedata.BooleanLiveData

/**
 * @author :zhouh
 * email：zhouhe@sixarm.cn
 * time：2020-06-01
 * company：山东六臂网络科技有限公司
 * desc：lifecycle观察者
 */
object KtxAppLifeObserver : LifecycleObserver {
    var isForeground = BooleanLiveData()

    //在前台
    @OnLifecycleEvent(Lifecycle.Event.ON_START)
    private fun onForeground() {
        isForeground.value = true
    }

    //在后台
    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    private fun onBackground() {
        isForeground.value = false
    }
}